package com.app.controller;

import com.app.pojo.Poster;
import com.app.pojo.Result;
import com.app.service.OrderService;
import com.app.service.PosterService;
import javafx.geometry.Pos;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/poster")
@CrossOrigin
public class PosterController {
    @Autowired
    PosterService posterService;

    //获取所有海报
    @GetMapping("/all")
    public Result getAll() {
        List<Poster> list = posterService.showAll();
        return Result.success(list);
    }

    //新增海报
    @PostMapping("/create")
    public Result createPoster(@RequestBody Poster poster){
        posterService.insert(poster);
        return Result.success();
    }

    //删除海报
    @DeleteMapping("/delete/{img_id}")
    public Result deletePoster(@PathVariable int img_id){
        posterService.delete(img_id);
        return Result.success();
    }
}
